package dbcontrol

import "MqttCloudProtocolServer/publiclib/datamodel/dborm"

//SavedbConfControl struct
type SavedbConfControl struct {
	base dbOperabase
	Data *dborm.Savedbconf
}

//CreateSavedbConfControl 初始化几种指针函数
func CreateSavedbConfControl() *SavedbConfControl {
	content := new(SavedbConfControl)
	content.base.GetData = func() interface{} {
		return content.Data
	}
	content.base.SetData = func(data interface{}) {
		if data != nil {
			content.Data = data.(*dborm.Savedbconf)
		}
	}
	content.base.GetKey = func() interface{} {
		if content.Data == nil {
			return nil
		}
		return content.Data.ID
	}
	content.base.CreateNew = func() interface{} {
		res := new(dborm.Savedbconf)
		res.ID = ""
		return res
	}
	content.base.CreateNil = func() interface{} {
		return new(dborm.Savedbconf)
	}
	return content
}

//GetAll 获取全部用户-服务器映射信息
func (_this *SavedbConfControl) GetAll() ([]*dborm.Savedbconf, error) {
	res := make([]*dborm.Savedbconf, 0)
	_, err := _this.base.GetAllByPage(&res, 0, 0, 0)
	return res, err
}

//FindByID 根据主键获取一条记录
func (_this *SavedbConfControl) FindByID(id string) error {
	return _this.base.FindByID(id)
}
